<template>
  <div class="css-demo">
    <h2 class="section-title">CSS3 特性演示</h2>
    
    <div class="demo-grid">
      <!-- 渐变和阴影 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>渐变和阴影</h3>
          <button class="code-toggle" @click="toggleCode('gradient')">
            {{ showCode.gradient ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.gradient">
            <pre class="code-viewer"><code>.linear-gradient {
  background: linear-gradient(45deg, #00ff88, #00a1ff);
}

.radial-gradient {
  background: radial-gradient(circle at center, #00ff88, #00a1ff);
}

.conic-gradient {
  background: conic-gradient(from 45deg, #00ff88, #00a1ff, #00ff88);
}</code></pre>
          </div>
          <div class="gradient-box">
            <div class="linear-gradient">线性渐变</div>
            <div class="radial-gradient">径向渐变</div>
            <div class="conic-gradient">锥形渐变</div>
          </div>
        </div>
      </div>

      <!-- 变换和过渡 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>变换和过渡</h3>
          <button class="code-toggle" @click="toggleCode('transform')">
            {{ showCode.transform ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.transform">
            <pre class="code-viewer"><code>.rotate:hover {
  transform: rotate(45deg);
}

.scale:hover {
  transform: scale(1.2);
}

.skew:hover {
  transform: skew(10deg);
}

.translate:hover {
  transform: translateY(-10px);
}</code></pre>
          </div>
          <div class="transform-container">
            <div class="transform-box rotate">旋转</div>
            <div class="transform-box scale">缩放</div>
            <div class="transform-box skew">倾斜</div>
            <div class="transform-box translate">位移</div>
          </div>
        </div>
      </div>

      <!-- 动画效果 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>动画效果</h3>
          <button class="code-toggle" @click="toggleCode('animation')">
            {{ showCode.animation ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.animation">
            <pre class="code-viewer"><code>@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-30px); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes wave {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-20px) rotate(90deg); }
  50% { transform: translateY(0) rotate(180deg); }
  75% { transform: translateY(20px) rotate(270deg); }
}</code></pre>
          </div>
          <div class="animation-container">
            <div class="floating-circle"></div>
            <div class="pulse-circle"></div>
            <div class="wave-circle"></div>
          </div>
        </div>
      </div>

      <!-- 响应式布局 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>响应式布局</h3>
          <button class="code-toggle" @click="toggleCode('responsive')">
            {{ showCode.responsive ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.responsive">
            <pre class="code-viewer"><code>.responsive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 1rem;
}

@media (max-width: 768px) {
  .responsive-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}</code></pre>
          </div>
          <div class="responsive-grid">
            <div class="grid-item">1</div>
            <div class="grid-item">2</div>
            <div class="grid-item">3</div>
            <div class="grid-item">4</div>
          </div>
        </div>
      </div>

      <!-- Flexbox 布局 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>Flexbox 布局</h3>
          <button class="code-toggle" @click="toggleCode('flexbox')">
            {{ showCode.flexbox ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.flexbox">
            <pre class="code-viewer"><code>.flex-container {
  display: flex;
  flex-direction: v-bind(flexDirection);
  justify-content: v-bind(justifyContent);
  align-items: v-bind(alignItems);
  gap: 1rem;
  min-height: 150px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 1rem;
}</code></pre>
          </div>
          <div class="flex-container">
            <div class="flex-item">1</div>
            <div class="flex-item">2</div>
            <div class="flex-item">3</div>
            <div class="flex-item">4</div>
            <div class="flex-item">5</div>
          </div>
          <div class="flex-controls">
            <button @click="toggleFlexDirection">切换方向</button>
            <button @click="toggleJustifyContent">切换对齐</button>
            <button @click="toggleAlignItems">切换垂直对齐</button>
          </div>
        </div>
      </div>

      <!-- CSS 变量 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 变量</h3>
          <button class="code-toggle" @click="toggleCode('variables')">
            {{ showCode.variables ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.variables">
            <pre class="code-viewer"><code>:root {
  --primary-color: #00ff88;
  --secondary-color: #00a1ff;
  --accent-color: #ff6b6b;
}

.variable-box.primary {
  background: var(--primary-color);
}

.variable-box.secondary {
  background: var(--secondary-color);
}

.variable-box.accent {
  background: var(--accent-color);
}</code></pre>
          </div>
          <div class="css-variables-demo">
            <div class="variable-box primary">主色调</div>
            <div class="variable-box secondary">次色调</div>
            <div class="variable-box accent">强调色</div>
          </div>
          <div class="variable-controls">
            <div class="control-group">
              <label>主色调</label>
              <input type="color" v-model="primaryColor" @input="updateCssVariables">
            </div>
            <div class="control-group">
              <label>次色调</label>
              <input type="color" v-model="secondaryColor" @input="updateCssVariables">
            </div>
            <div class="control-group">
              <label>强调色</label>
              <input type="color" v-model="accentColor" @input="updateCssVariables">
            </div>
          </div>
        </div>
      </div>

      <!-- 媒体查询 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>媒体查询</h3>
          <button class="code-toggle" @click="toggleCode('media')">
            {{ showCode.media ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.media">
            <pre class="code-viewer"><code>@media (max-width: 768px) {
  .responsive-text {
    font-size: 0.9rem;
    color: var(--primary-color);
  }
}

@media (min-width: 769px) {
  .responsive-text {
    font-size: 1.1rem;
    color: var(--secondary-color);
  }
}</code></pre>
          </div>
          <div class="media-query-demo">
            <div class="screen-size">
              当前屏幕宽度: <span class="size-value">{{ screenWidth }}px</span>
            </div>
            <div class="responsive-box">
              <div class="responsive-text">
                这个元素会根据屏幕大小改变样式
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 过渡和动画 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>过渡和动画</h3>
          <button class="code-toggle" @click="toggleCode('transition')">
            {{ showCode.transition ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.transition">
            <pre class="code-viewer"><code>.transition-box {
  transition: all 0.5s ease;
}

.transition-active {
  transform: scale(1.2) rotate(10deg);
  background: linear-gradient(45deg, var(--accent-color), var(--primary-color));
}

.animation-active {
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}</code></pre>
          </div>
          <div class="transition-demo">
            <div class="transition-box" :class="{ 'transition-active': isTransitionActive }">
              过渡效果
            </div>
            <button @click="toggleTransition">触发过渡</button>
          </div>
          <div class="animation-demo">
            <div class="animation-box" :class="{ 'animation-active': isAnimationActive }">
              动画效果
            </div>
            <button @click="toggleAnimation">触发动画</button>
          </div>
        </div>
      </div>

      <!-- 滤镜效果 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>滤镜效果</h3>
          <button class="code-toggle" @click="toggleCode('filter')">
            {{ showCode.filter ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.filter">
            <pre class="code-viewer"><code>.filter-item:nth-child(1) {
  filter: blur(5px);
}

.filter-item:nth-child(2) {
  filter: brightness(150%);
}

.filter-item:nth-child(3) {
  filter: contrast(150%);
}

.filter-item:nth-child(4) {
  filter: grayscale(100%);
}

.filter-item:nth-child(5) {
  filter: sepia(100%);
}

.filter-item:nth-child(6) {
  filter: hue-rotate(90deg);
}</code></pre>
          </div>
          <div class="filter-demo">
            <div class="filter-image">
              <div class="filter-overlay"></div>
            </div>
            <div class="filter-controls">
              <div class="filter-item" :style="{ filter: 'blur(5px)' }">模糊</div>
              <div class="filter-item" :style="{ filter: 'brightness(150%)' }">亮度</div>
              <div class="filter-item" :style="{ filter: 'contrast(150%)' }">对比度</div>
              <div class="filter-item" :style="{ filter: 'grayscale(100%)' }">灰度</div>
              <div class="filter-item" :style="{ filter: 'sepia(100%)' }">棕褐色</div>
              <div class="filter-item" :style="{ filter: 'hue-rotate(90deg)' }">色相旋转</div>
            </div>
          </div>
        </div>
      </div>

      <!-- 3D 变换 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>3D 变换</h3>
          <button class="code-toggle" @click="toggleCode('transform3d')">
            {{ showCode.transform3d ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.transform3d">
            <pre class="code-viewer"><code>.transform-3d-box {
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

.transform-3d-box {
  transform: rotateX(v-bind(rotateX)deg) 
             rotateY(v-bind(rotateY)deg) 
             rotateZ(v-bind(rotateZ)deg);
}</code></pre>
          </div>
          <div class="transform-3d-container">
            <div class="transform-3d-box" :style="transform3DStyle">
              3D 变换
            </div>
            <div class="transform-3d-controls">
              <div class="control-group">
                <label>X 轴旋转</label>
                <input type="range" v-model="rotateX" min="-180" max="180" @input="update3DTransform">
              </div>
              <div class="control-group">
                <label>Y 轴旋转</label>
                <input type="range" v-model="rotateY" min="-180" max="180" @input="update3DTransform">
              </div>
              <div class="control-group">
                <label>Z 轴旋转</label>
                <input type="range" v-model="rotateZ" min="-180" max="180" @input="update3DTransform">
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 逻辑属性 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 逻辑属性</h3>
          <button class="code-toggle" @click="toggleCode('logical')">
            {{ showCode.logical ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.logical">
            <pre class="code-viewer"><code>.logical-container {
  margin-inline: auto;
  padding-block: 1rem;
  border-inline: 2px solid var(--primary-color);
}

.logical-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
}</code></pre>
          </div>
          <div class="logical-demo">
            <div class="logical-container">
              <div class="logical-text">垂直文本</div>
            </div>
          </div>
        </div>
      </div>

      <!-- 伪类 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>伪类</h3>
          <button class="code-toggle" @click="toggleCode('pseudo-class')">
            {{ showCode.pseudoClass ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.pseudoClass">
            <pre class="code-viewer"><code>/* 交互状态伪类 */
.pseudo-btn:hover {
  background: rgba(0, 255, 136, 0.2);
  transform: translateY(-2px);
}

.pseudo-btn:active {
  background: rgba(0, 255, 136, 0.4);
  transform: translateY(0);
}

.pseudo-btn:focus {
  outline: 2px solid var(--primary-color);
}

/* 结构伪类 */
.structure-item:first-child {
  background: rgba(0, 255, 136, 0.2);
}

.structure-item:last-child {
  background: rgba(0, 161, 255, 0.2);
}

.structure-item:nth-child(odd) {
  transform: translateX(5px);
}

.structure-item:nth-child(even) {
  transform: translateX(-5px);
}

/* 表单伪类 */
.form-group input:checked + label {
  color: var(--primary-color);
  font-weight: bold;
}

.form-group input:focus {
  outline: 2px solid var(--primary-color);
  background: rgba(0, 255, 136, 0.1);
}

.form-group button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}</code></pre>
          </div>
          <div class="pseudo-class-demo">
            <div class="pseudo-section">
              <h4>交互状态</h4>
              <div class="pseudo-interactive">
                <button class="pseudo-btn">悬停我</button>
                <button class="pseudo-btn">点击我</button>
                <button class="pseudo-btn" tabindex="0">焦点我</button>
              </div>
            </div>
            
            <div class="pseudo-section">
              <h4>结构选择器</h4>
              <div class="pseudo-structure">
                <div class="structure-item">项目 1</div>
                <div class="structure-item">项目 2</div>
                <div class="structure-item">项目 3</div>
                <div class="structure-item">项目 4</div>
                <div class="structure-item">项目 5</div>
              </div>
            </div>
            
            <div class="pseudo-section">
              <h4>表单状态</h4>
              <div class="pseudo-form">
                <div class="form-group">
                  <input type="checkbox" id="checkbox1">
                  <label for="checkbox1">选中我</label>
                </div>
                <div class="form-group">
                  <input type="text" placeholder="输入一些内容">
                </div>
                <div class="form-group">
                  <button disabled>禁用按钮</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 伪元素 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>伪元素</h3>
          <button class="code-toggle" @click="toggleCode('pseudo-element')">
            {{ showCode.pseudoElement ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.pseudoElement">
            <pre class="code-viewer"><code>/* ::first-letter */
.first-letter-demo::first-letter {
  font-size: 2.5rem;
  color: var(--primary-color);
  float: left;
  margin-right: 0.5rem;
}

/* ::first-line */
.first-line-demo::first-line {
  color: var(--primary-color);
  font-weight: bold;
}

/* ::before 和 ::after */
.before-after-demo::before {
  content: "「";
  color: var(--primary-color);
}

.before-after-demo::after {
  content: "」";
  color: var(--accent-color);
}

/* ::selection */
.selection-demo::selection {
  background: var(--primary-color);
  color: white;
}

/* ::placeholder */
.placeholder-demo::placeholder {
  color: var(--accent-color);
  font-style: italic;
}</code></pre>
          </div>
          <div class="pseudo-element-demo">
            <div class="pseudo-section">
              <h4>::first-letter</h4>
              <p class="first-letter-demo">首字母大写效果</p>
            </div>
            
            <div class="pseudo-section">
              <h4>::first-line</h4>
              <p class="first-line-demo">这是第一行文本，会显示为特殊样式。这是第二行文本，会显示为默认样式。</p>
            </div>
            
            <div class="pseudo-section">
              <h4>::before 和 ::after</h4>
              <div class="before-after-demo">前后缀</div>
            </div>
            
            <div class="pseudo-section">
              <h4>::selection</h4>
              <div class="selection-demo">选择这段文本查看效果</div>
            </div>
            
            <div class="pseudo-section">
              <h4>::placeholder</h4>
              <input type="text" class="placeholder-demo" placeholder="这是一个占位符">
            </div>
          </div>
        </div>
      </div>

      <!-- CSS Grid 高级特性 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS Grid 高级特性</h3>
          <button class="code-toggle" @click="toggleCode('grid')">
            {{ showCode.grid ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.grid">
            <pre class="code-viewer"><code>.grid-container {
  display: grid;
  grid-template-areas: 
    "header header header"
    "nav main aside"
    "footer footer footer";
  grid-template-columns: 200px 1fr 200px;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
}

.grid-header { grid-area: header; }
.grid-nav { grid-area: nav; }
.grid-main { grid-area: main; }
.grid-aside { grid-area: aside; }
.grid-footer { grid-area: footer; }

/* 自动放置 */
.auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}</code></pre>
          </div>
          <div class="grid-demo">
            <div class="grid-container">
              <div class="grid-header">Header</div>
              <div class="grid-nav">Navigation</div>
              <div class="grid-main">Main Content</div>
              <div class="grid-aside">Sidebar</div>
              <div class="grid-footer">Footer</div>
            </div>
            <div class="auto-grid">
              <div class="auto-item">1</div>
              <div class="auto-item">2</div>
              <div class="auto-item">3</div>
              <div class="auto-item">4</div>
              <div class="auto-item">5</div>
              <div class="auto-item">6</div>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 变量高级用法 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 变量高级用法</h3>
          <button class="code-toggle" @click="toggleCode('variables')">
            {{ showCode.variables ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.variables">
            <pre class="code-viewer"><code>:root {
  --primary-hue: 160;
  --primary-color: hsl(var(--primary-hue), 100%, 50%);
  --spacing-unit: 8px;
  --spacing-small: calc(var(--spacing-unit) * 1);
  --spacing-medium: calc(var(--spacing-unit) * 2);
  --spacing-large: calc(var(--spacing-unit) * 3);
}

.theme-dark {
  --bg-color: #1a1a1a;
  --text-color: #ffffff;
}

.theme-light {
  --bg-color: #ffffff;
  --text-color: #1a1a1a;
}</code></pre>
          </div>
          <div class="variables-demo">
            <div class="theme-switcher">
              <button @click="toggleTheme">切换主题</button>
            </div>
            <div class="spacing-demo">
              <div class="spacing-box small">小间距</div>
              <div class="spacing-box medium">中间距</div>
              <div class="spacing-box large">大间距</div>
            </div>
            <div class="color-demo">
              <div class="color-box" :style="{ '--hue': 160 }">绿色</div>
              <div class="color-box" :style="{ '--hue': 200 }">蓝色</div>
              <div class="color-box" :style="{ '--hue': 280 }">紫色</div>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 打印样式 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 打印样式</h3>
          <button class="code-toggle" @click="toggleCode('print')">
            {{ showCode.print ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.print">
            <pre class="code-viewer"><code>@media print {
  .print-demo {
    color: black;
    background: white;
  }

  .print-page {
    page-break-after: always;
  }

  .print-no-break {
    page-break-inside: avoid;
  }

  .print-header {
    position: running(header);
  }

  .print-footer {
    position: running(footer);
  }

  @page {
    margin: 2cm;
    @top-center {
      content: element(header);
    }
    @bottom-center {
      content: element(footer);
    }
  }
}</code></pre>
          </div>
          <div class="print-demo">
            <div class="print-page">
              <div class="print-header">页眉</div>
              <div class="print-content">
                <h2>第一页</h2>
                <p>这是第一页的内容，打印时会自动分页。</p>
              </div>
              <div class="print-footer">页脚</div>
            </div>
            <div class="print-page">
              <div class="print-header">页眉</div>
              <div class="print-content">
                <h2>第二页</h2>
                <p>这是第二页的内容。</p>
                <div class="print-no-break">
                  <h3>这个部分不会在打印时被分页</h3>
                  <p>即使内容很长也不会被分页。</p>
                </div>
              </div>
              <div class="print-footer">页脚</div>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 内容可见性 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 内容可见性</h3>
          <button class="code-toggle" @click="toggleCode('content-visibility')">
            {{ showCode.contentVisibility ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.contentVisibility">
            <pre class="code-viewer"><code>.content-visibility-demo {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

.content-visibility-hidden {
  content-visibility: hidden;
  contain-intrinsic-size: 0 500px;
}

.content-visibility-visible {
  content-visibility: visible;
  contain-intrinsic-size: 0 500px;
}</code></pre>
          </div>
          <div class="content-visibility-demo">
            <div class="visibility-controls">
              <button @click="toggleVisibility('auto')">自动</button>
              <button @click="toggleVisibility('hidden')">隐藏</button>
              <button @click="toggleVisibility('visible')">显示</button>
            </div>
            <div class="visibility-content" :class="visibilityClass">
              <div v-for="i in 10" :key="i" class="visibility-item">
                <h3>项目 {{ i }}</h3>
                <p>这是一些示例内容，用于演示内容可见性属性。</p>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 容器查询 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 容器查询</h3>
          <button class="code-toggle" @click="toggleCode('container')">
            {{ showCode.container ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.container">
            <pre class="code-viewer"><code>.container {
  container-type: inline-size;
}

@container (min-width: 400px) {
  .container-item {
    grid-template-columns: repeat(2, 1fr);
  }
}

@container (min-width: 600px) {
  .container-item {
    grid-template-columns: repeat(3, 1fr);
  }
}</code></pre>
          </div>
          <div class="container-demo">
            <div class="container-controls">
              <button @click="resizeContainer('small')">小容器</button>
              <button @click="resizeContainer('medium')">中容器</button>
              <button @click="resizeContainer('large')">大容器</button>
            </div>
            <div class="container" :class="containerSize">
              <div class="container-item">
                <div class="item">1</div>
                <div class="item">2</div>
                <div class="item">3</div>
                <div class="item">4</div>
                <div class="item">5</div>
                <div class="item">6</div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 子网格 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 子网格</h3>
          <button class="code-toggle" @click="toggleCode('subgrid')">
            {{ showCode.subgrid ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.subgrid">
            <pre class="code-viewer"><code>.subgrid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.subgrid-item {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: span 3;
}</code></pre>
          </div>
          <div class="subgrid-demo">
            <div class="subgrid-container">
              <div class="subgrid-item">
                <div class="subgrid-content">1</div>
                <div class="subgrid-content">2</div>
                <div class="subgrid-content">3</div>
              </div>
              <div class="subgrid-item">
                <div class="subgrid-content">4</div>
                <div class="subgrid-content">5</div>
                <div class="subgrid-content">6</div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 滚动条样式 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 滚动条样式</h3>
          <button class="code-toggle" @click="toggleCode('scrollbar')">
            {{ showCode.scrollbar ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.scrollbar">
            <pre class="code-viewer"><code>.scrollbar-demo {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.2);
}

.scrollbar-demo::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.scrollbar-demo::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.scrollbar-demo::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}</code></pre>
          </div>
          <div class="scrollbar-demo">
            <div class="scrollbar-content">
              <div v-for="i in 20" :key="i" class="scrollbar-item">
                滚动内容 {{ i }}
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 背景高级属性 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 背景高级属性</h3>
          <button class="code-toggle" @click="toggleCode('background')">
            {{ showCode.background ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.background">
            <pre class="code-viewer"><code>.background-demo {
  background-image: 
    linear-gradient(45deg, rgba(0,255,136,0.2) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0,255,136,0.2) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0,255,136,0.2) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0,255,136,0.2) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-clip: padding-box;
  background-origin: padding-box;
}</code></pre>
          </div>
          <div class="background-demo">
            <div class="background-content">
              <h3>多背景图案</h3>
              <p>使用多个背景图层创建复杂的图案效果</p>
            </div>
          </div>
        </div>
      </div>

      <!-- CSS 文本效果 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 文本效果</h3>
          <button class="code-toggle" @click="toggleCode('text')">
            {{ showCode.text ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.text">
            <pre class="code-viewer"><code>.text-gradient {
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-shadow {
  text-shadow: 
    2px 2px 0 var(--primary-color),
    4px 4px 0 var(--accent-color);
}

.text-stroke {
  -webkit-text-stroke: 1px var(--primary-color);
  color: transparent;
}</code></pre>
          </div>
          <div class="text-demo">
            <h2 class="text-gradient">渐变文本</h2>
            <h2 class="text-shadow">阴影文本</h2>
            <h2 class="text-stroke">描边文本</h2>
          </div>
        </div>
      </div>

      <!-- CSS 视口单位 -->
      <div class="demo-card group">
        <div class="demo-header">
          <h3>CSS 视口单位</h3>
          <button class="code-toggle" @click="toggleCode('viewport')">
            {{ showCode.viewport ? '隐藏代码' : '查看代码' }}
          </button>
        </div>
        <div class="demo-content">
          <div class="code-block" v-if="showCode.viewport">
            <pre class="code-viewer"><code>.viewport-demo {
  width: 100%;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.viewport-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.viewport-text {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  line-height: 1.2;
  margin: 0;
  max-width: 100%;
  word-wrap: break-word;
}

.viewport-content p {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  margin: 0;
  max-width: 100%;
  word-wrap: break-word;
}

.viewport-text {
  font-size: 5vw;
  line-height: 1.2;
}</code></pre>
          </div>
          <div class="viewport-demo">
            <div class="viewport-content">
              <h2 class="viewport-text">响应式文本</h2>
              <p>这个容器使用视口单位来调整大小</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue'

// 代码显示控制
const showCode = ref({
  gradient: false,
  transform: false,
  animation: false,
  responsive: false,
  flexbox: false,
  variables: false,
  media: false,
  transition: false,
  filter: false,
  transform3d: false,
  blend: false,
  mask: false,
  scroll: false,
  shape: false,
  counter: false,
  logical: false,
  pseudoClass: false,
  pseudoElement: false,
  grid: false,
  print: false,
  contentVisibility: false,
  container: false,
  subgrid: false,
  scrollbar: false,
  background: false,
  text: false,
  viewport: false
})

const toggleCode = (section) => {
  showCode.value[section] = !showCode.value[section]
}

// Flexbox 控制
const flexDirection = ref('row')
const justifyContent = ref('flex-start')
const alignItems = ref('stretch')

const toggleFlexDirection = () => {
  flexDirection.value = flexDirection.value === 'row' ? 'column' : 'row'
}

const toggleJustifyContent = () => {
  const options = ['flex-start', 'center', 'flex-end', 'space-between', 'space-around']
  const currentIndex = options.indexOf(justifyContent.value)
  const nextIndex = (currentIndex + 1) % options.length
  justifyContent.value = options[nextIndex]
}

const toggleAlignItems = () => {
  const options = ['stretch', 'center', 'flex-start', 'flex-end']
  const currentIndex = options.indexOf(alignItems.value)
  const nextIndex = (currentIndex + 1) % options.length
  alignItems.value = options[nextIndex]
}

// CSS 变量
const primaryColor = ref('#00ff88')
const secondaryColor = ref('#00a1ff')
const accentColor = ref('#ff6b6b')

const updateCssVariables = () => {
  document.documentElement.style.setProperty('--primary-color', primaryColor.value)
  document.documentElement.style.setProperty('--secondary-color', secondaryColor.value)
  document.documentElement.style.setProperty('--accent-color', accentColor.value)
}

// 媒体查询
const screenWidth = ref(window.innerWidth)

const updateScreenWidth = () => {
  screenWidth.value = window.innerWidth
}

// 过渡和动画
const isTransitionActive = ref(false)
const isAnimationActive = ref(false)

const toggleTransition = () => {
  isTransitionActive.value = !isTransitionActive.value
}

const toggleAnimation = () => {
  isAnimationActive.value = !isAnimationActive.value
}

// 3D 变换
const rotateX = ref(0)
const rotateY = ref(0)
const rotateZ = ref(0)

const transform3DStyle = computed(() => {
  return {
    transform: `rotateX(${rotateX.value}deg) rotateY(${rotateY.value}deg) rotateZ(${rotateZ.value}deg)`
  }
})

const update3DTransform = () => {
  // 触发计算属性更新
}

// 生命周期钩子
onMounted(() => {
  window.addEventListener('resize', updateScreenWidth)
  updateCssVariables()
})

onUnmounted(() => {
  window.removeEventListener('resize', updateScreenWidth)
})

const visibilityClass = ref('content-visibility-auto')
const containerSize = ref('container-small')

const toggleVisibility = (type) => {
  visibilityClass.value = `content-visibility-${type}`
}

const resizeContainer = (size) => {
  containerSize.value = `container-${size}`
}

const toggleTheme = () => {
  document.body.classList.toggle('theme-dark')
  document.body.classList.toggle('theme-light')
}
</script>

<style scoped>
.css-demo {
  padding: 2rem;
}

.section-title {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  text-align: center;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.demo-card {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 15px;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.demo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.demo-header h3 {
  font-size: 1.5rem;
  margin: 0;
  color: var(--primary-color);
}

.code-toggle {
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  color: #00ff88;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.code-toggle:hover {
  background: rgba(0, 255, 136, 0.2);
}

.demo-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.code-block {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.code-viewer {
  width: 100%;
  margin: 0;
  padding: 1rem;
  background: transparent;
  color: #b8e0d2;
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-x: auto;
}

.code-viewer code {
  display: block;
  width: 100%;
}

/* 渐变效果 */
.gradient-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.gradient-box > div {
  height: 100px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.linear-gradient {
  background: linear-gradient(45deg, #00ff88, #00a1ff);
}

.radial-gradient {
  background: radial-gradient(circle at center, #00ff88, #00a1ff);
}

.conic-gradient {
  background: conic-gradient(from 45deg, #00ff88, #00a1ff, #00ff88);
}

/* 变换效果 */
.transform-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.transform-box {
  height: 100px;
  background: rgba(0, 255, 136, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.transform-box:hover {
  background: rgba(0, 255, 136, 0.3);
}

.rotate:hover {
  transform: rotate(45deg);
}

.scale:hover {
  transform: scale(1.2);
}

.skew:hover {
  transform: skew(10deg);
}

.translate:hover {
  transform: translateY(-10px);
}

/* 动画效果 */
.animation-container {
  height: 200px;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  overflow: hidden;
}

.floating-circle {
  width: 50px;
  height: 50px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 50%;
  position: absolute;
  left: 20%;
  animation: float 3s ease-in-out infinite;
}

.pulse-circle {
  width: 50px;
  height: 50px;
  background: linear-gradient(-45deg, var(--primary-color), var(--secondary-color));
  border-radius: 50%;
  position: absolute;
  left: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.wave-circle {
  width: 50px;
  height: 50px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: 50%;
  position: absolute;
  left: 80%;
  animation: wave 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-30px); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes wave {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-20px) rotate(90deg); }
  50% { transform: translateY(0) rotate(180deg); }
  75% { transform: translateY(20px) rotate(270deg); }
}

/* 响应式布局 */
.responsive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 1rem;
}

.grid-item {
  aspect-ratio: 1;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  transition: all 0.3s ease;
}

.grid-item:hover {
  transform: scale(1.1) rotate(10deg);
}

/* Flexbox 布局 */
.flex-container {
  display: flex;
  flex-direction: v-bind(flexDirection);
  justify-content: v-bind(justifyContent);
  align-items: v-bind(alignItems);
  gap: 1rem;
  min-height: 150px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 1rem;
}

.flex-item {
  flex: 1;
  min-height: 50px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: white;
  transition: all 0.3s ease;
}

.flex-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* CSS 变量 */
.css-variables-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.variable-box {
  height: 100px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.variable-box.primary {
  background: var(--primary-color);
}

.variable-box.secondary {
  background: var(--secondary-color);
}

.variable-box.accent {
  background: var(--accent-color);
}

.variable-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.control-group label {
  min-width: 80px;
}

.control-group input[type="color"] {
  width: 100%;
  height: 30px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

/* 媒体查询 */
.media-query-demo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.screen-size {
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  text-align: center;
}

.size-value {
  font-weight: bold;
  color: var(--primary-color);
}

.responsive-box {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  transition: all 0.3s ease;
}

.responsive-text {
  text-align: center;
  transition: all 0.3s ease;
}

/* 伪类演示 */
.pseudo-class-demo {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.pseudo-section {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 1.5rem;
}

.pseudo-section h4 {
  margin: 0 0 1rem 0;
  color: var(--primary-color);
  font-size: 1.2rem;
}

/* 交互状态伪类 */
.pseudo-interactive {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pseudo-btn {
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 5px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pseudo-btn:hover {
  background: rgba(0, 255, 136, 0.2);
  transform: translateY(-2px);
}

.pseudo-btn:active {
  background: rgba(0, 255, 136, 0.4);
  transform: translateY(0);
}

.pseudo-btn:focus {
  outline: 2px solid var(--primary-color);
  background: rgba(0, 255, 136, 0.3);
}

/* 结构伪类 */
.pseudo-structure {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.structure-item {
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  transition: all 0.3s ease;
}

.structure-item:first-child {
  background: rgba(0, 255, 136, 0.2);
  font-weight: bold;
}

.structure-item:last-child {
  background: rgba(0, 161, 255, 0.2);
  font-weight: bold;
}

.structure-item:nth-child(odd) {
  transform: translateX(5px);
}

.structure-item:nth-child(even) {
  transform: translateX(-5px);
}

/* 表单伪类 */
.pseudo-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.form-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.form-group input[type="checkbox"]:checked + label {
  color: var(--primary-color);
  font-weight: bold;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 5px;
  color: white;
}

.form-group input[type="text"]:focus {
  outline: 2px solid var(--primary-color);
  background: rgba(0, 255, 136, 0.1);
}

.form-group button {
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 5px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.form-group button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.1);
}

/* 伪元素演示 */
.pseudo-element-demo {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.pseudo-element-demo .pseudo-section {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 1.5rem;
}

.pseudo-element-demo .pseudo-section h4 {
  margin: 0 0 1rem 0;
  color: var(--primary-color);
  font-size: 1.2rem;
}

.first-letter-demo {
  font-size: 1.1rem;
  line-height: 1.5;
}

.first-letter-demo::first-letter {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--primary-color);
  float: left;
  margin-right: 0.5rem;
  line-height: 1;
}

.first-line-demo {
  font-size: 1.1rem;
  line-height: 1.5;
}

.first-line-demo::first-line {
  color: var(--primary-color);
  font-weight: bold;
}

.before-after-demo {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  text-align: center;
  position: relative;
}

.before-after-demo::before {
  content: "「";
  color: var(--primary-color);
  position: absolute;
  left: 0.5rem;
}

.before-after-demo::after {
  content: "」";
  color: var(--accent-color);
  position: absolute;
  right: 0.5rem;
}

.selection-demo {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  text-align: center;
  cursor: text;
}

.selection-demo::selection {
  background: var(--primary-color);
  color: white;
}

.placeholder-demo {
  width: 100%;
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 5px;
  color: white;
}

.placeholder-demo::placeholder {
  color: var(--accent-color);
  font-style: italic;
}

@media (max-width: 768px) {
  .pseudo-class-demo,
  .pseudo-element-demo {
    gap: 1rem;
  }

  .pseudo-section {
    padding: 1rem;
  }

  .pseudo-interactive,
  .pseudo-structure,
  .pseudo-form {
    gap: 0.3rem;
  }
}

/* 过渡和动画 */
.transition-demo,
.animation-demo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.transition-box,
.animation-box {
  height: 100px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
}

.transition-box {
  transition: all 0.5s ease;
}

.transition-active {
  transform: scale(1.2) rotate(10deg);
  background: linear-gradient(45deg, var(--accent-color), var(--primary-color));
}

.animation-box {
  animation: none;
}

.animation-active {
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

/* 滤镜效果 */
.filter-demo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-image {
  height: 150px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}

.filter-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none" stroke="white" stroke-width="2"/><circle cx="50" cy="50" r="30" fill="none" stroke="white" stroke-width="2"/></svg>') center/cover;
  opacity: 0.3;
}

.filter-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.filter-item {
  height: 80px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem;
}

/* 3D 变换 */
.transform-3d-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.transform-3d-box {
  height: 150px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

.transform-3d-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transform-3d-controls .control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.transform-3d-controls label {
  min-width: 80px;
}

.transform-3d-controls input[type="range"] {
  flex: 1;
}

/* 混合模式 */
.blend-mode-demo {
  width: 100%;
  height: 200px;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}

.blend-mode-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.blend-layer {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.base-layer {
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  z-index: 1;
}

.blend-multiply {
  background: rgba(255, 0, 0, 0.5);
  mix-blend-mode: multiply;
  z-index: 2;
}

.blend-screen {
  background: rgba(0, 255, 0, 0.5);
  mix-blend-mode: screen;
  z-index: 2;
}

.blend-overlay {
  background: rgba(0, 0, 255, 0.5);
  mix-blend-mode: overlay;
  z-index: 2;
}

.blend-soft-light {
  background: rgba(255, 255, 0, 0.5);
  mix-blend-mode: soft-light;
  z-index: 2;
}

.blend-hard-light {
  background: rgba(255, 0, 255, 0.5);
  mix-blend-mode: hard-light;
  z-index: 2;
}

/* 遮罩效果 */
.mask-demo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mask-container,
.mask-gradient {
  height: 150px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  overflow: hidden;
}

.mask-content {
  width: 100%;
  height: 100%;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none" stroke="white" stroke-width="2"/><circle cx="50" cy="50" r="30" fill="none" stroke="white" stroke-width="2"/></svg>') center/cover;
}

.mask-gradient {
  -webkit-mask-image: linear-gradient(to right, transparent, black);
  mask-image: linear-gradient(to right, transparent, black);
}

/* 滚动捕捉 */
.scroll-snap-demo {
  width: 100%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.scroll-container {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: 1rem;
  padding: 1rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scroll-container::-webkit-scrollbar {
  display: none;
}

.scroll-item {
  flex: 0 0 300px;
  height: 200px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  transition: transform 0.3s ease;
}

.scroll-item:hover {
  transform: scale(1.05);
}

/* CSS 形状 */
.shape-demo {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.shape-container {
  width: 150px;
  height: 150px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  shape-outside: circle(50%);
  float: left;
  margin-right: 1rem;
  border-radius: 50%;
}

.shape-text {
  shape-margin: 20px;
  line-height: 1.6;
  text-align: justify;
}

/* CSS 计数器 */
.counter-demo {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.counter-container {
  counter-reset: section;
}

.counter-item {
  counter-increment: section;
  padding: 0.8rem;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  transition: all 0.3s ease;
}

.counter-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(10px);
}

.counter-item::before {
  content: counter(section) ". ";
  color: var(--primary-color);
  font-weight: bold;
}

/* CSS 逻辑属性 */
.logical-demo {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.logical-container {
  margin-inline: auto;
  padding-block: 1rem;
  border-inline: 2px solid var(--primary-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 150px;
}

.logical-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 1.5rem;
  color: var(--primary-color);
  letter-spacing: 0.5rem;
}

/* CSS Grid 高级特性 */
.grid-demo {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.grid-container {
  display: grid;
  grid-template-areas: 
    "header header header"
    "nav main aside"
    "footer footer footer";
  grid-template-columns: 200px 1fr 200px;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 10px;
}

.grid-header { grid-area: header; }
.grid-nav { grid-area: nav; }
.grid-main { grid-area: main; }
.grid-aside { grid-area: aside; }
.grid-footer { grid-area: footer; }

.auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.auto-item {
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  padding: 1rem;
  border-radius: 5px;
  text-align: center;
  color: white;
}

/* CSS 变量高级用法 */
.variables-demo {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.theme-switcher {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.spacing-demo {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-medium);
}

.spacing-box {
  background: rgba(0, 0, 0, 0.2);
  padding: var(--spacing-medium);
  border-radius: 5px;
}

.spacing-box.small { padding: var(--spacing-small); }
.spacing-box.medium { padding: var(--spacing-medium); }
.spacing-box.large { padding: var(--spacing-large); }

.color-demo {
  display: flex;
  gap: 1rem;
}

.color-box {
  flex: 1;
  height: 100px;
  background: hsl(var(--hue), 100%, 50%);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* CSS 打印样式 */
.print-demo {
  background: white;
  color: black;
  padding: 1rem;
  border-radius: 10px;
}

.print-page {
  margin-bottom: 2rem;
  padding: 1rem;
  border: 1px solid #ccc;
}

.print-header {
  text-align: center;
  padding: 1rem;
  border-bottom: 1px solid #ccc;
}

.print-content {
  padding: 1rem;
}

.print-footer {
  text-align: center;
  padding: 1rem;
  border-top: 1px solid #ccc;
}

.print-no-break {
  background: #f5f5f5;
  padding: 1rem;
  margin: 1rem 0;
}

/* CSS 内容可见性 */
.content-visibility-demo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.visibility-controls {
  display: flex;
  gap: 1rem;
}

.visibility-content {
  height: 300px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 1rem;
}

.visibility-item {
  margin-bottom: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
}

.content-visibility-auto {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

.content-visibility-hidden {
  content-visibility: hidden;
  contain-intrinsic-size: 0 500px;
}

.content-visibility-visible {
  content-visibility: visible;
  contain-intrinsic-size: 0 500px;
}

/* CSS 容器查询 */
.container-demo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.container-controls {
  display: flex;
  gap: 1rem;
}

.container {
  container-type: inline-size;
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 10px;
}

.container-small {
  width: 300px;
}

.container-medium {
  width: 500px;
}

.container-large {
  width: 700px;
}

.container-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@container (min-width: 400px) {
  .container-item {
    grid-template-columns: repeat(2, 1fr);
  }
}

@container (min-width: 600px) {
  .container-item {
    grid-template-columns: repeat(3, 1fr);
  }
}

.item {
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  padding: 1rem;
  border-radius: 5px;
  text-align: center;
  color: white;
}

/* CSS 子网格 */
.subgrid-demo {
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 10px;
}

.subgrid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.subgrid-item {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: span 3;
}

.subgrid-content {
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  padding: 1rem;
  border-radius: 5px;
  text-align: center;
  color: white;
}

/* CSS 滚动条样式 */
.scrollbar-demo {
  height: 300px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 1rem;
}

.scrollbar-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.scrollbar-item {
  background: rgba(255, 255, 255, 0.1);
  padding: 1rem;
  border-radius: 5px;
}

.scrollbar-demo {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.2);
}

.scrollbar-demo::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.scrollbar-demo::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.scrollbar-demo::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

/* CSS 背景高级属性 */
.background-demo {
  height: 200px;
  background-image: 
    linear-gradient(45deg, rgba(0,255,136,0.2) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0,255,136,0.2) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0,255,136,0.2) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0,255,136,0.2) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-clip: padding-box;
  background-origin: padding-box;
  border-radius: 10px;
  padding: 1rem;
}

.background-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 5px;
  padding: 1rem;
}

/* CSS 文本效果 */
.text-demo {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  text-align: center;
}

.text-gradient {
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 2rem;
}

.text-shadow {
  text-shadow: 
    2px 2px 0 var(--primary-color),
    4px 4px 0 var(--accent-color);
  font-size: 2rem;
}

.text-stroke {
  -webkit-text-stroke: 1px var(--primary-color);
  color: transparent;
  font-size: 2rem;
}

/* CSS 视口单位 */
.viewport-demo {
  width: 100%;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.viewport-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.viewport-text {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  line-height: 1.2;
  margin: 0;
  max-width: 100%;
  word-wrap: break-word;
}

.viewport-content p {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  margin: 0;
  max-width: 100%;
  word-wrap: break-word;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .grid-container {
    grid-template-areas: 
      "header"
      "nav"
      "main"
      "aside"
      "footer";
    grid-template-columns: 1fr;
  }

  .color-demo {
    flex-direction: column;
  }

  .container-small,
  .container-medium,
  .container-large {
    width: 100%;
  }

  .viewport-demo {
    width: 100%;
    height: 300px;
  }
}
</style> 